package com.atguigu.inherited;

public class Rectangle extends Graphic{//矩形
    private double length;//长
    private double width;//宽

    //构造器
    public Rectangle() {
       // 这里默认调用父类Graphic的无参构造
    }

    public Rectangle(String name, double length, double width) {
        //如果没写 super(name); 默认也找父类的无参构造
        super(name);
        this.length = length;
        this.width = width;
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public String getInfo(){
//        return "矩形名称：" + name ;//父类的name是private修饰，子类不能直接使用
        return "矩形名称：" + getName() +"，长：" + length +",宽：" + width;
    }
}
